#include "pch.hpp"
#include "entry.hpp"

using namespace logger;




entry::entry(Level lvl, QString message, QString module, QString file, QString function, std::size_t line, std::size_t column, boost::posix_time::ptime time)
	: lvl(lvl)
	, message(message)
	, module(module)
	, file(file)
	, function(function)
	, line(line)
	, time(time)
{}
///////////////////////////////////////////////////////////////////////////////////////////////////

entry::entry(Level lvl, QString message, QString module, QString file, QString function, std::size_t line, std::size_t column)
	: lvl(lvl)
	, message(message)
	, module(module)
	, file(file)
	, function(function)
	, line(line)
	, time(boost::posix_time::microsec_clock::local_time())
{}
///////////////////////////////////////////////////////////////////////////////////////////////////




bool entry::operator==(const entry& that) const
{
	if(lvl != that.lvl)
		return false;
	if(message != that.message)
		return false;
	if(module != that.module)
		return false;
	if(file != that.file)
		return false;
	if(function != that.function)
		return false;
	if(line != that.line)
		return false;
	if(time != that.time)
		return false;

	return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////




const char* entry::toString(Level lvl)
{
	switch(lvl)
	{
	case exception: return "exception";
	case error:     return "error";
	case warning:   return "warning";
	case info:      return "info";
	case debug:     return "debug";
	default:        return "unknown";
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
